package com.yanqu.road.entity.guess.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.guess.CommonGuessRewardItem;
import com.yanqu.road.entity.player.CrossUserBaseInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_c_activity_common_guess_main", desc = "通用竞猜-竞猜主表")
public class CommonGuessMain extends DataObject {

    /**
     * 活动ID
     */
    private int activityId;

    /**
     * 分组ID
     */
    private int groupId;

    /**
     * 轮次
     */
    private int round;

    /**
     * 战场ID
     */
    private int siteId;

    /**
     * 类型1竞猜商会2竞猜玩家
     */
    private int type;

    /**
     * 玩法类型，1：冠亚军竞猜
     */
    private int playType;

    /**
     * 可竞猜数
     */
    private int guessNum;

    /**
     * 竞猜开始时间
     */
    private long startTime;

    /**
     * 竞猜结束时间
     */
    private long endTime;

    /**
     * 竞猜展示结束时间
     */
    private long endShowTime;

    /**
     * 等待结果结束时间
     */
    private long endWaitResultTime;

    /**
     * 结果排名逗号隔开
     */
    private String rankResult;

    /**
     * 奖励
     */
    private List<CommonGuessRewardItem> reward = new ArrayList<>();

    /**
     * 创建时间
     */
    private long createTime;

    /**
     * 完成奖励的玩家MAP缓存。K:奖励ID,V:玩家baseUserInfoList
     */
    private Map<Integer, List<CrossUserBaseInfo>> rewardCompleteUserMap = new ConcurrentHashMap<>();

    public CommonGuessMain() {
    }

    public CommonGuessMain(int activityId, int groupId, int round, int siteId, int type, int playType, int guessNum, long startTime, long endTime, long endWaitResultTime, long endShowTime, List<CommonGuessRewardItem> reward) {
        this.activityId = activityId;
        this.groupId = groupId;
        this.round = round;
        this.siteId = siteId;
        this.type = type;
        this.playType = playType;
        this.guessNum = guessNum;
        this.startTime = startTime;
        this.endTime = endTime;
        this.endWaitResultTime = endWaitResultTime;
        this.endShowTime = endShowTime;
        this.reward = reward;
        this.rankResult = "";
        this.createTime = System.currentTimeMillis();
        setInsertOption();
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public int getRound() {
        return round;
    }

    public void setRound(int round) {
        if (this.round != round) {
            this.round = round;
            setOp(DataStatus.Update);
        }
    }

    public int getSiteId() {
        return siteId;
    }

    public void setSiteId(int siteId) {
        if (this.siteId != siteId) {
            this.siteId = siteId;
            setOp(DataStatus.Update);
        }
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        if (this.type != type) {
            this.type = type;
            setOp(DataStatus.Update);
        }
    }

    public int getPlayType() {
        return playType;
    }

    public void setPlayType(int playType) {
        if (this.playType != playType) {
            this.playType = playType;
            setOp(DataStatus.Update);
        }
    }

    public int getGuessNum() {
        return guessNum;
    }

    public void setGuessNum(int guessNum) {
        if (this.guessNum != guessNum) {
            this.guessNum = guessNum;
            setOp(DataStatus.Update);
        }
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        if (this.startTime != startTime) {
            this.startTime = startTime;
            setOp(DataStatus.Update);
        }
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        if (this.endTime != endTime) {
            this.endTime = endTime;
            setOp(DataStatus.Update);
        }
    }

    public long getEndWaitResultTime() {
        return endWaitResultTime;
    }

    public void setEndWaitResultTime(long endWaitResultTime) {
        if (this.endWaitResultTime != endWaitResultTime) {
            this.endWaitResultTime = endWaitResultTime;
            setOp(DataStatus.Update);
        }
    }

    public long getEndShowTime() {
        return endShowTime;
    }

    public void setEndShowTime(long endShowTime) {
        if (this.endShowTime != endShowTime) {
            this.endShowTime = endShowTime;
            setOp(DataStatus.Update);
        }
    }

    public String getRankResult() {
        return rankResult;
    }

    public void setRankResult(String rankResult) {
        if (!Objects.equals(this.rankResult, rankResult)) {
            this.rankResult = rankResult;
            setOp(DataStatus.Update);
        }
    }

    public List<CommonGuessRewardItem> getReward() {
        return reward;
    }

    public void setReward(List<CommonGuessRewardItem> reward) {
        if (!Objects.equals(this.reward, reward)) {
            this.reward = reward;
            setOp(DataStatus.Update);
        }
    }

    public long getCreateTime() {
        return createTime;
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        if (this.groupId != groupId) {
            this.groupId = groupId;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, List<CrossUserBaseInfo>> getRewardCompleteUserMap() {
        return rewardCompleteUserMap;
    }

    public void setRewardCompleteUserMap(Map<Integer, List<CrossUserBaseInfo>> rewardCompleteUserMap) {
        this.rewardCompleteUserMap = rewardCompleteUserMap;
    }
}
